package com.atguigu.mvc.controller;

import com.atguigu.mvc.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
public class ParamController {


    @RequestMapping("/testServletAPI")
    public String testServletAPI(HttpServletRequest request){
        HttpSession session = request.getSession();
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        System.out.println("password = " + password);
        System.out.println("username = " + username);
        return "success";
    }


    @RequestMapping("/testParam")
    public String testParam(
            @RequestParam("username") String username, String password, String hobby,
            @RequestHeader("Host") String host
            ){
        System.out.println("password = " + password);
        System.out.println("username = " + username);
        System.out.println("hobby = " + hobby);
        System.out.println("host = " + host);
        return "success";
    }

    @RequestMapping("/testBean")
    public String testBean(User user){
        System.out.println(user);
        return "success";
    }



}
